home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / campki~1.zip / CAMPER.QC < prev    next >
Text File  |  1996-10-05  |  4KB  |  139 lines

  1. /* CAMPER.QC - Proximity Monitoring Version!
  2.  
  3. Based on Original code by: James Starling <starling@mgl.ca>
  4.  
  5. */
  6.  
  7.  
  8. /* -------------------------------------------------------------------------
  9. Changes outside of this file to original Quake source...
  10.  
  11. 1) add these fields to the defs.qc in the "player only" section
  12. .float  camp_time;            // next camping check
  13. .float  camp_count;            // number of camping warnings
  14. .vector    camp_origin;        // location of last check
  15.  
  16. 2) add this line to "PlayerPreThink" function in client.qc
  17. CheckForCamper();
  18.  
  19. 3) add camper.qc before client.qc in the progs.src file
  20.  
  21. -------------------------------------------------------------------------- */
  22.  
  23. // functional prototypes of existing Quake functions
  24. entity () SelectSpawnPoint;
  25. void (vector org) spawn_tfog;
  26.  
  27. void() GibPlayer;        //MRB to kill camper
  28. void() DeathSound;
  29.  
  30. // internal definitions of camping times warnings
  31. float CAMPER_CHECK                 = 1;
  32. float CAMPER_DISTANCE                 = 200;
  33. float CAMPER_HEALTH_PERCENT            = 0.5;
  34.  
  35. // resets the camper fields in the player entity
  36. void() ResetCamperFields =
  37. {
  38.     // reset the player's next camper check
  39.     self.camp_count = 0;
  40.     self.camp_time = time + CAMPER_CHECK;
  41.     self.camp_origin = self.origin;
  42. };
  43.  
  44. // Executes the teleportation of the camper - NOT CALLED ANYMORE
  45. void () TeleportCamper = 
  46. {
  47.     local entity spawn_point;
  48.  
  49.     // get a spawn point to teleport to
  50.     spawn_point = SelectSpawnPoint ();
  51.  
  52.     // set the new spawn_point as the player's origin
  53.     self.origin = spawn_point.origin + '0 0 1';
  54.     self.angles = spawn_point.angles;
  55.     self.fixangle = TRUE;        // turn this way immediately
  56.  
  57.     // decrement the players health to teach them a lesson
  58.     self.health = ( self.health * CAMPER_HEALTH_PERCENT ) + 0.5;
  59.  
  60.     ResetCamperFields();
  61.  
  62.     // make it look like the player was teleported
  63.     self.teleport_time = time + 5;
  64.     spawn_tfog ( self.origin );
  65.  
  66. };
  67.  
  68. void () scream_like_a_pig =
  69. {
  70.     local float rs;        //random-sound
  71.  
  72.     rs = rint((random() * 5) + 1);        // If he's ill scream!
  73.     self.noise = "";
  74.     if (rs == 1) self.noise = "player/pain1.wav";
  75.     else if (rs == 2) self.noise = "player/pain2.wav";
  76.     else if (rs == 3) self.noise = "player/pain3.wav";
  77.     else if (rs == 4) self.noise = "player/pain4.wav";
  78.     else if (rs == 5) self.noise = "player/pain5.wav";
  79.     else self.noise = "player/pain6.wav";
  80.     sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  81.     stuffcmd(self, "bf");
  82. };
  83.  
  84. // get current location of player and compare to the location of the last check
  85. void() CheckForCamper =
  86. {
  87.     // this code will only executes in multiplayer modes
  88.     if( deathmatch || coop )
  89.     {
  90.         if( ( vlen( self.camp_origin - self.origin ) >= CAMPER_DISTANCE ) ||
  91.             ( self.health <= 0 ) || !self.camp_time )
  92.         {
  93.             ResetCamperFields();
  94.         }
  95.         // see if the player has exceeded their camping permit
  96.         else if( time >= self.camp_time )
  97.         {
  98.             // increase the camping count
  99.             self.camp_count = self.camp_count + 1;
  100.             self.camp_time = time + CAMPER_CHECK;
  101.  
  102.             // first warning
  103.             if( self.camp_count == 7 )
  104.             {
  105.                 // warn the player
  106.                 centerprint ( self, "You're not camping, are you?\n" );
  107.                 scream_like_a_pig();
  108.                 bprint(self.netname);        
  109.                 bprint(" is camping! \n");
  110.             }
  111.             // second warning
  112.             else if( self.camp_count == 10 )    //Was=11
  113.             {
  114.                 // warn the player
  115.                 centerprint ( self, "Still camping, eh?\n" );
  116.                 scream_like_a_pig();
  117.                 bprint(self.netname);        
  118.                 bprint(" is STILL camping! \n");
  119. //                TeleportCamper();    //inclusion of this resets all?
  120.                 // decrement the players health to teach them a lesson
  121.                 self.health = ( self.health * CAMPER_HEALTH_PERCENT ) + 0.5;
  122.             }
  123.             // exceeded camping time for the last time
  124.             else if( self.camp_count > 15 )
  125.             {
  126.                 centerprint ( self, "I bet that hurt!  :-) \n" );
  127.                 // tell the other players
  128.                 bprint(self.netname);
  129.                 bprint(" was Gibbed for being a WussBoy Camper!\n"); 
  130.                 DeathSound();
  131.                 self.health = 0;    //KILL
  132.                     GibPlayer();
  133.                 self.frags = self.frags - 2;    // extra penalty on frags though!
  134.             }
  135.         }
  136.     }
  137. };
  138.  
  139.